/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package biz;

import entity.Teachers;
import entityBean.TeachersFacade;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;

/**
 *
 * @author ADMIN
 */
public class teachersbiz {

    TeachersFacade teachersFacade = lookupTeachersFacadeBean();
    List<Teachers> list = new ArrayList<Teachers>();
    Teachers teachers = new Teachers();

    public teachersbiz() {
    }

    public List<Teachers> listTeachers() {
        list = teachersFacade.findAll();
        return list;
    }

    public Teachers findTeachersById(int id) {
        teachers = teachersFacade.find(id);
        return teachers;
    }

    private TeachersFacade lookupTeachersFacadeBean() {
        try {
            Context c = new InitialContext();
            return (TeachersFacade) c.lookup("java:global/Cms_Portal_Source/Cms_Portal_Source-ejb/TeachersFacade!entityBean.TeachersFacade");
        } catch (NamingException ne) {
            Logger.getLogger(getClass().getName()).log(Level.SEVERE, "exception caught", ne);
            throw new RuntimeException(ne);
        }
    }
}
